<?php

namespace App\Models\Participant;

class ParticipantService
{
    public $participantRepository;

    public function __construct(\App\Contracts\Repositories\ParticipantRepository $participantRepository)
    {
        $this->participantRepository = $participantRepository;
    }

    public function getParticipantbyId($id)
    {
        return $this->participantRepository->getParticipantById($id);
    }

    public function getParticipantIdByOpenID($openID, $source)
    {
        return $this->participantRepository->getParticipantIdByOpenID($openID, $source);
    }

    public function createParticipant($openID, $source)
    {
        $existParticipant = $this->getParticipantIdByOpenID($openID, $source);
        if (!empty($existParticipant)) {
            return $existParticipant;
        }
        return $this->participantRepository->createParticipant($openID, $source);
    }

    public function getParticipantByEmptyName()
    {
        return $this->participantRepository->findUserByEmptyName();
    }

    public function getParticipantByOpenID($openID)
    {
        return $this->participantRepository->getParticipantByOpenID($openID);
    }

}
